# compare.py
import time

# 导入纯 Python 版本
from pure_python_sum import loop_sum as pure_python_sum

# 导入 Cython 版本
import cython_sum

n = 10**7

# 测试纯 Python 版本
start_time = time.time()
result_python = pure_python_sum(n)
end_time = time.time()
print(f"Pure Python sum: {result_python}, time: {end_time - start_time} seconds")

# 测试 Cython 版本
start_time = time.time()
result_cython = cython_sum.loop_sum(n)
end_time = time.time()
print(f"Cython sum: {result_cython}, time: {end_time - start_time} seconds")

# 验证结果是否一致
assert result_python == result_cython, "The results do not match!"